package operation;

import Beans.Student;
import User.User;
import Utils.SQLSentencePoll;
import dao.DataOperation;

import java.util.List;

/**
 * 显示学生信息的功能对象
 */
public class ShowStudentInfo implements IOperation{
    @Override
    public boolean operate(User user) {
        System.out.println("+------------------------- 显示学生信息 -------------------------+");
        List<Student> studentsList = DataOperation.query(Student.class, SQLSentencePoll.AllAccountsInfoDisplay);
        if(studentsList != null){
            for (Student student : studentsList){
                System.out.println(student);
            }
            System.out.println("+------------------------- 共" + studentsList.size() + "条学生记录 ------------------------+");
        }else{
            System.out.println("暂无学生记录！");
            System.out.println("+------------------------------------------------+");
        }
        return true;
    }
}
